package ee.edi.common;

import java.io.InputStream;
import java.util.Properties;

public enum Config {
	XSTONE_URL("xstoneUrl", "http://localhost:8888");

	static final String PROPERTIES_FILE = "WEB-INF/config.xml";

	static Properties props = null;
	String key;
	String value;
	
	private Config(String key, String defaultValue) {
		this.key = key;
		this.value = defaultValue;
	}
	
	public String toString() {
		if (props == null) init();
		return props.getProperty(key, value);
	}

	protected static void init() {
		InputStream is = Config.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE);
		props = new Properties();
		try {
			props.loadFromXML(is);
		} catch (Exception e) {
			throw new ServiceException(e);
		}
	}
}
